#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
 
#define PAGE_SIZE     4096
 
int main ( int argc, char **argv )
{
    int configfd;
    char * address = NULL;
    if(argc!=2) {
        printf("Usage: %s [vvsfs_file]\n", argv[0]);
        return 0;
    }
 
    configfd = open(argv[1], O_RDWR);
    if(configfd < 0)
    {
        perror("Open call failed");
        return -1;
    }
     
    address = mmap(NULL, PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, configfd, 0);
    if (address == MAP_FAILED)
    {
        perror("mmap operation failed");
        return -1;
    }
 
    printf("raw content: %s\n", address);
    memcpy(address, "**mmap_test**", 13);
    memcpy(address+1, "abnhahahah**", 12);
    printf("change content: %s\n", address);
    close(configfd);    
    return 0;
}
